package Terminal.UI;

import java.awt.Dimension;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;


public class TabComposite extends PanelComponent{
	protected JTabbedPane tabpanel;
	
	public TabComposite(PanelComponent parent){super(parent);
	tabpanel = new JTabbedPane();
	pannellocomponente = new JPanel(null);
	}
	
	public JPanel createComponents() {
		tabpanel.setLocation(30, 5);
		pannellocomponente.add(tabpanel);
		setSize(1300, 450);

		return pannellocomponente;
	}
	
	public void add(PanelComponent figlio) {
		super.add(figlio);
		JScrollPane scrollpanetemp = new JScrollPane(figlio.createComponents());
		tabpanel.addTab(" ",null,scrollpanetemp," ");
		tabpanel.setSelectedIndex(0);
		//updateSize();
	}	
	
	public void addTitle(PanelComponent figlio, String title){
		super.add(figlio);
		JScrollPane scrollpanetemp = new JScrollPane(figlio.createComponents());
		//scrollpanetemp.setPreferredSize(new Dimension( 1366, 525));
		scrollpanetemp.setPreferredSize(new Dimension( 1300, 450));
		scrollpanetemp.setSize(scrollpanetemp.getPreferredSize());
		tabpanel.addTab(title, null, scrollpanetemp,title);
		tabpanel.setSelectedIndex(0);
		
		//updateSize();
		//tabpanel.repaint();
		
	}
	
	public void setTitle(int index, String title)
	{
		tabpanel.setTitleAt(index, title);
	}
	
	public void setTitle(String title){
		tabpanel.setTitleAt(tabpanel.getTabCount()-1, title);
	}
	
	public void remove(int index ){
		super.remove(index);
		tabpanel.remove(index);
	}
	
	public void updateSize(){}
	
	public void setSize(int width, int height){
		Dimension d= new Dimension(width,height);
		super.setSize(d);
		tabpanel.setSize(d);
		tabpanel.setPreferredSize(d);
		tabpanel.setPreferredSize(d);

	}
	public void setSize(Dimension d){
		
		super.setSize(d);
		tabpanel.setSize(d);
		tabpanel.setPreferredSize(d);
		tabpanel.setPreferredSize(d);
	}
}
	


